package com.chanzany.principle.singleResponsibility;

public class SingleResonsibility2 {
    public static void main(String[] args) {
        new RoadVehicle().run("摩托车");
        new RoadVehicle().run("汽车");
        new AirVehicle().run("飞机");
    }
}

/**
 * 方式2：
 *  遵守了单一职责原则，但是这样做的改动很大，需要修改客户端代码
 *  改进：直接修改Vehicle类，改动的代码会比较少
 */
class RoadVehicle{
    public void run(String vehicle){
        System.out.println(vehicle+"在公路上跑");
    }
}
class AirVehicle{
    public void run(String vehicle){
        System.out.println(vehicle+"在天空上跑");
    }
}
class WaterVehicle{
    public void run(String vehicle){
        System.out.println(vehicle+"在水上跑");
    }
}